<template>
  <div class="home">
    <van-cell-group class="my-info">
       <!-- icon="chat_o" -->
      <van-cell class="base-info" center :border="false">
        <van-image slot="icon" class="avatar" round fit="cover" :src="require('./../assets/logo.png')"/>
      <div class="name" slot="title">admin</div>
      <!-- <van-icon name="chat_o" size="40"> -->
      <!-- <van-cell title="单元格" value="内容" /> -->
      </van-cell>
      <div class="largeTitle">
        <div class="title">
          <span>今日作业人数</span>
          <span>{{taskPesCount}}</span>
        </div>
        <div class="title">
          <span>今日事件数</span>
          <span>{{eventCount}}</span>
        </div>
        <div class="title">
          <span>今日任务数</span>
          <span>{{taskCount}}</span>
        </div>
      </div>
    </van-cell-group>
    <van-grid class="nav-grid mb-4" :column-num="2">
      <van-grid-item to="task" class="nav-grid-item" icon="envelop-o" text="任务"/>
      <van-grid-item to="event" class="nav-grid-item" icon="sign" text="事件"/>
    </van-grid>
    <van-cell class="mb-4" style="color:#aeadbd" title="修改密码" is-link to="/pwd"/>
    <van-cell class="logout-cell" title="退出登录"/>
  </div>
</template>

<script>
// @ is an alias to /src

export default {
  name: 'home',
  components: {},
  methods:{
      async getUserInfo(){
        let userId=sessionStorage.getItem("set_token").split("-")
        var url=this.$location.getUserById;
        var res=await this.request({
          url:url,
          data:{
            id:userId,
          }
        })
        console.log(res);
      },
      async geteventCount(){
        const res=await this.request({
          url:"/app/Event/getCurrEventCount"
        });
        console.log(res);
        this.eventCount=res.data;
      },
      async gettaskCount(){
        const res=await this.request({
          url:"/app/Task/getCurrTaskCount"
        });
        this.taskCount=res.data;
      },
      async gettaskPesCount(){
         const res=await this.request({
          url:"/app/Task/getCurrTaskPerCount"
        });
        this.taskPesCount=res.data;
      }
  },
  data(){
      return{
        username:"",
        phone:"",
        icon:"",
        eventCount:undefined,
        taskCount:undefined,
        taskPesCount:undefined
      }
  },
  created(){
      // this.getUserInfo();
      this.geteventCount();
      this.gettaskCount();
      this.gettaskPesCount()
  }
}
</script>

<style lang="scss">
.mb-4{
  margin-bottom: 4px;
  color: #d86262;
}
.van-cell_title{
  color: rgb(157, 154, 173);
}
.logout-cell{
  // .van-cell_title{
    color: #d86262 !important;
    text-align: center;
  // }
}
.largeTitle{
  display: flex;
  flex-direction: row;
  justify-content: space-around;
}
.title{
  display: flex;
  flex-direction: column;
  align-items: center;
  color: white;
  font-size: 14px;
  margin-bottom: 20px;
  span{
    margin: 5px;
  }
}
.my-info{
  background: url('../assets/2.jpg') no-repeat;
  background-size: cover;
  .base-info{
    height: 115px;
    box-sizing: border-box;
    background-color: unset;
  }
  .avatar{
    box-sizing: border-box;
    width: 66px;
    height: 66px;
    border: 1px solid #fff;
    margin-right: 11px;
  }
  .name{
    font-size: 15px;
    color: #fff;
  }
}
</style>
